﻿using System;

namespace SfsTools.Core
{
    /// <summary>
    /// Common interface for <see cref="IDirectory"/> and <see cref="IFile"/>.
    /// </summary>
    public interface IFileSystemObject
    {
        /// <summary>
        /// Gets the name of this <see cref="IFileSystemObject"/>.
        /// </summary>
        String Name
        {
            get;
        }

#if false
        /// <summary>
        /// Gets a value indicating whether this <see cref="IFileSystemObject"/> is deleted.
        /// </summary>
        Boolean IsDeleted
        {
            get;
        }
#endif

        /// <summary>
        /// Gets the time stamp when the <see cref="IFileSystemObject"/> was last updated.
        /// </summary>
        TimeStamp LastUpdate
        {
            get;
        }

        /// <summary>
        /// Gets the <see cref="IDirectory"/> this <see cref="IFileSystemObject"/> is located in.
        /// </summary>
        IDirectory Parent
        {
            get;
        }

        /// <summary>
        /// Returns the full path to the <see cref="IFileSystemObject"/>.
        /// </summary>
        /// <returns></returns>
        String GetFullPath();

        /// <summary>
        /// Renames this <see cref="IFileSystemObject"/> to <paramref name="name"/>.
        /// </summary>
        /// <param name="name">The new name of this <see cref="IFileSystemObject"/>.</param>
        /// <exception cref="ArgumentNullException">The argument <paramref name="name"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentException">The argument <paramref name="name"/> contains invalid characters.</exception>
        /// <exception cref="InvalidOperationException">The parent directory already contains a <see cref="IFileSystemObject"/> with <paramref name="name"/>.</exception>
        /// <exception cref="IndexAreaFullException">Cannot allocate entries because the index area is full.</exception>
        /// <exception cref="System.IO.PathTooLongException">The full path is too long.</exception>
        /// <exception cref="System.IO.IOException">An I/O exception occurred.</exception>
        void Rename(String name);

        /// <summary>
        /// Deletes this <see cref="IFileSystemObject"/>.
        /// </summary>
        /// <exception cref="InvalidOperationException">The <see cref="IFileSystemObject"/> is already deleted.</exception>
        /// <exception cref="System.IO.IOException">An I/O exception occurred.</exception>
        void Delete();

#if false
        /// <summary>
        /// Restores this <see cref="IFileSystemObject"/> that was previously deleted.
        /// </summary>
        /// <exception cref="InvalidOperationException">The <see cref="IFileSystemObject"/> is not deleted.</exception>
        /// <exception cref="System.IO.IOException">An I/O exception occurred.</exception>
        /// <exception cref="IndexAreaFullException">Cannot create <see cref="IFileSystemObject"/> because the index area is full.</exception>
        void Resurrect();
#endif

        /// <summary>
        /// Accepts a visitor.
        /// </summary>
        /// <param name="visitor">The visitor.</param>
        /// <exception cref="ArgumentNullException">The argument <paramref name="visitor"/> is <see langword="null"/>.</exception>
        void AcceptVisitor(IFileSystemObjectVisitor visitor);
    }
}
